﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="ettevotja_muudatus_kandeelement", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(EttevotjaMuudatusKandeelement))]
    public class EttevotjaMuudatusKandeelementSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IEttevotjaMuudatusKandeelement clazz;
        
        public EttevotjaMuudatusKandeelementSerializer(IEttevotjaMuudatusKandeelement clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.KandeelemendiId!=null) {
                Writer.WriteStartElement("kandeelemendi_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.KandeelemendiId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KandeelemendiLiik!=null) {
                Writer.WriteStartElement("kandeelemendi_liik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KandeelemendiLiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KandeelemendiJrk!=null) {
                Writer.WriteStartElement("kandeelemendi_jrk");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.KandeelemendiJrk))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KandeelemendiKehtivus!=null) {
                Writer.WriteStartElement("kandeelemendi_kehtivus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KandeelemendiKehtivus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TyhistatavaKandeId!=null) {
                Writer.WriteStartElement("tyhistatava_kande_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TyhistatavaKandeId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TyhistatavaKandeNr!=null) {
                Writer.WriteStartElement("tyhistatava_kande_nr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.TyhistatavaKandeNr))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="kandeelemendi_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandeelement>kandeelemendi_id");
                }
                clazz.KandeelemendiId = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("kandeelemendi_id")).Value;
            }
            if (Reader.LocalName=="kandeelemendi_liik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandeelement>kandeelemendi_liik");
                }
                clazz.KandeelemendiLiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kandeelemendi_liik")).Value;
            }
            if (Reader.LocalName=="kandeelemendi_jrk") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandeelement>kandeelemendi_jrk");
                }
                clazz.KandeelemendiJrk = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("kandeelemendi_jrk")).Value;
            }
            if (Reader.LocalName=="kandeelemendi_kehtivus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandeelement>kandeelemendi_kehtivus");
                }
                clazz.KandeelemendiKehtivus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kandeelemendi_kehtivus")).Value;
            }
            if (Reader.LocalName=="tyhistatava_kande_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandeelement>tyhistatava_kande_id");
                }
                clazz.TyhistatavaKandeId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tyhistatava_kande_id")).Value;
            }
            if (Reader.LocalName=="tyhistatava_kande_nr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandeelement>tyhistatava_kande_nr");
                }
                clazz.TyhistatavaKandeNr = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("tyhistatava_kande_nr")).Value;
            }
        }
    }
}
